package com.hifar.test.entrust.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hifar.test.entrust.mapper.HfEnvPieceMapper;
import com.hifar.test.entrust.pojo.HfEnvPiece;
import com.hifar.test.entrust.service.IHfEnvPieceService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 * 委托单样品 服务实现类
 * </p>
 *
 * @author wei
 * @since 2024-12-04 15:51:56
 */
@Service
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public class HfEnvPieceServiceImpl extends ServiceImpl<HfEnvPieceMapper, HfEnvPiece> implements IHfEnvPieceService {

	@Override
	public void removeByEntrustId(String entrustId) {
		QueryWrapper<HfEnvPiece> queryWrapper = new QueryWrapper<>();
		queryWrapper.lambda()
				.eq(HfEnvPiece::getEntrustId, entrustId);
		this.remove(queryWrapper);
	}

	@Override
	public List<HfEnvPiece> listByEntrustId(String entrustId) {
		QueryWrapper<HfEnvPiece> queryWrapper = new QueryWrapper<>();
		queryWrapper.lambda()
				.eq(HfEnvPiece::getEntrustId, entrustId)
				.orderByAsc(HfEnvPiece::getRowSort);
		return this.list(queryWrapper);
	}
}
